<template>
    

<!-- home界面 -->
<el-container class="homecon">
  <el-header>
      <div>
     <img src="../assets/mar2.jpg" width="50px" height="50px"> 
    <span id="wodan">电商管理系统</span>
       

      </div>
      <el-button type="info" @click="outdex">退出</el-button>
      
      </el-header>
    <!-- 左侧栏 -->
  <el-container>
    <el-aside :width="iscolllapse ? '64px' :'200px'  "> <el-menu
      background-color="#333744"
      text-color="#fff"
      active-text-color="#409bff" :unique-opened="true" :collapse="iscolllapse" :collapse-transition="false" :router="true" :default-active="$route.path">
      <div class="toggle-button" @click="zhedie" >|||</div>

      <el-submenu :index="item.id+''"    v-for="item in menulist" :key="item.id">  
        <template slot="title">
          <i :class="iconsobj[item.id]" ></i>
          <span>{{item.authName}}</span>
        </template>
        
        <el-menu-item :index="'/'+sub.path" v-for="sub in item.children" :key="sub.id" >
          <template slot="title">
          <i class="el-icon-menu"></i>
          <span>{{sub.authName}}</span>
        </template>
          </el-menu-item>
        </el-submenu>
     
   
    </el-menu>
    </el-aside>
    <!-- 结束侧边栏 -->
    <el-main>
        <router-view></router-view>
    </el-main>
  </el-container>
</el-container>

   
</template>

<script>
export default {
 data(){
return{
    menulist:[] ,
    iconsobj:{'125':'el-icon-s-custom',
             '103':'el-icon-s-check',
             '101':'el-icon-s-unfold',
             '102':'el-icon-share',
             '145':'el-icon-s-data'
    
    },
    iscolllapse:false
    }
},
created(){this.getMenuList();},


  methods:{
     
    outdex(){
        window.sessionStorage.clear();
        this.$router.push('/login')
    },
   async getMenuList(){
  const {data:res} =await this.$http.get('menus')
if(res.meta.status!=200) return this.$message.error(res.meta.msg);
          this.menulist=res.data
       
         
    },
    zhedie(){
  this.iscolllapse=!this.iscolllapse;
    }


  }
}
</script>


<style lang="less" scoped>
.el-header{background-color: #373d41;display: flex; 
justify-content: space-between;padding-left: 0;align-items: center;}
.el-aside{background-color: #333744;border-right: none;
.el-menu{border-right: none;}}
.el-main{background-color: #eaedf1;}
.homecon{height: 100vh;z-index: 1;}
img{position: absolute;top: 15px;border-radius: 50%;}
#wodan{color:#f5f5f5;position: absolute;left: 180px;top: 25px;align-items: center;font-size: 30px;}
.toggle-button{background-color: #4A5064;font-size: 10px;line-height: 24px;color: #fff;text-align: center;
letter-spacing: 0.2em;cursor: pointer;}

</style>